package com.jiang.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.stereotype.Service;

import com.jiang.service.IMessageService;
import com.jiang.vo.Message;
import com.jiang.vo.Type;

@Service
public class MessageServiceImpl implements IMessageService {

	@Override
	public boolean insert(Message msg) {

		System.out.println("插入数据: " + msg + "成功!");
		return true;
	}

	@Override
	public boolean update(Message msg) {
		System.out.println("更新数据:" + msg + "成功!");
		return true;
	}

	@Override
	public boolean delete(Set<Integer> ids) {

		System.out.println("删除主键为:" + ids + "数据成功!");
		return true;
	}

	@Override
	public Message get(int id) {
		Message msg = new Message();
		msg.setMid(id);
		msg.setPrice(100.0);
		msg.setPubDate(new Date());
		msg.setTitle("HIHI");
		Type type = new Type();
		type.setTypeTitle("你好啊");
		msg.setType(type);
		return msg;
	}

	@Override
	public Map<String, Object> list(String column, String keyWord, int currentPage, int lineSize) {

		Map<String, Object> map = new HashMap<>();
		List<Message> msgs = new ArrayList<Message>(10);
		// 模拟分页获取到的数据
		for (int i = 0; i < lineSize; i++) {
			Message msg = new Message();
			msg.setMid(i + 1);
			msg.setPrice(100.0 + i);
			msg.setPubDate(new Date());
			msg.setTitle("HIHI" + i);
			Type type = new Type();
			type.setTypeTitle("你好啊" + i);
			msg.setType(type);
			msgs.add(msg);
		}
		map.put("total", 888);
		map.put("data", msgs);
		return map;
	}

}
